import request from '@/utils/request'
const VUE_APP_USER_URL = process.env.VUE_APP_USER_URL
/**
 * 用户登录
 * http://showdoc.wisetimes.cn:4999/web/#/92/596
 * @param {*} data
 * @returns
 */
export function login (data) {
  return request({
    url: '/api/v1/bs/user/login',
    method: 'post',
    data
  })
}
/**
 * 检查用户在线状态
 * http://192.168.88.247:4999/web/#/14/194
 * @param {*} params
 * @returns
 */
export function checkStatus (params) {
  return request({
    url: VUE_APP_USER_URL + '/api/v1/check_status',
    method: 'get',
    params
  })
}
/**
 * 刷新token
 * http://showdoc.wisetimes.cn:4999/web/#/92/596
 * @returns
 */
export function refreshtoken () {
  return request({
    url: '/api/v1/bs/user/refresh',
    method: 'get'
  })
}
/**
 * 获取会员信息
 * http://showdoc.wisetimes.cn:4999/web/#/105/747
 * @returns
 */
export function getMemberInfo ({ noMsg }) {
  return request({
    noMsg,
    url: '/api/v1/member/info',
    method: 'get'
  })
}
/**
 * 获取连续包月信息
 * http://showdoc.wisetimes.cn:4999/web/#/105/2056
 * @returns
 */
export function getPeriodInfo (params) {
  return request({
    noMsg: true,
    url: '/api/v1/agreement/status/opened',
    method: 'get',
    params
  })
}
/**
 * 获取连续包月信息
 * http://showdoc.wisetimes.cn:4999/web/#/105/2057
 * @returns
 */
export function unSignPeriod (data) {
  return request({
    url: '/api/v1/agreement/unsign',
    method: 'post',
    data
  })
}
/**
 * 查看是否有权益包体验券可以领取
 * http://showdoc.wisetimes.cn:4999/web/#/105/1759
 * @returns
 */
export function getChangeExperienceInfo (data) {
  return request({
    url: '/api/v1/exp_coupon/has_change',
    method: 'post',
    data
  })
}
/**
 * 退出登录
 * http://showdoc.wisetimes.cn:4999/web/#/92/596
 * @returns
 */
export function logout () {
  return request({
    url: '/api/v1/bs/user/logout',
    method: 'get'
  })
}
/**
 * 注销账号
 * http://showdoc.wisetimes.cn:4999/web/#/92/596
 * @returns
 */
export function delUser (data) {
  return request({
    url: '/api/v1/member/logout',
    method: 'delete',
    data
  })
}

/**
 * 更新用户信息
 * http://showdoc.wisetimes.cn:4999/web/#/92/596
 * @returns
 */
export function updateUser (data) {
  return request({
    url: VUE_APP_USER_URL + '/api/v1/user',
    method: 'put',
    data
  })
}
/**
 * 获取用户设备列表
 * http://showdoc.wisetimes.cn:4999/web/#/92/596
 * @returns
 */
export function getDeviceList (params) {
  return request({
    url: VUE_APP_USER_URL + '/api/v1/device/list',
    method: 'get',
    params
  })
}

/**
 * 设备重命名
 * http://showdoc.wisetimes.cn:4999/web/#/92/596
 * @returns
 */
export function renameDevice (data) {
  return request({
    url: VUE_APP_USER_URL + '/api/v1/device/rename',
    method: 'post',
    data
  })
}

/**
 * 删除设备
 * http://192.168.88.247:4999/web/#/14/815
 * @returns
 */
export function delDevice (id) {
  return request({
    url: VUE_APP_USER_URL + '/api/v1/device/del',
    method: 'post',
    data: { id }
  })
}
/**
 * 上传头像
 * http://192.168.88.247:4999/web/#/14/815
 * @returns
 */
export function uploadImg (data) {
  return request({
    url: VUE_APP_USER_URL + '/api/v1/uploadImg',
    headers: {
      'content-type': 'multipart/form-data'
    },
    method: 'post',
    data
  })
}

/**
 * 获取产品列表
 * http://192.168.88.247:4999/web/#/105?page_id=2090
 * @returns
 */
export function getAllApp (params) {
  return request({
    url: '/api/v1/all_appid',
    method: 'get',
    params
  })
}
/**
 * 获取用户消息列表
 * http://192.168.88.247:4999/web/#/105/2628
 * @returns
 */
export function getMessageList (params) {
  return request({
    url: '/api/v1/message/list',
    method: 'get',
    params
  })
}
/**
 * 更新消息已读
 * http://192.168.88.247:4999/web/#/105/2762
 * @returns
 */
export function readMessage (data) {
  return request({
    url: '/api/v1/message/mark_read',
    method: 'post',
    data
  })
}
/**
 * 更新所有消息已读
 * http://192.168.88.247:4999/web/#/105/3323
 * @returns
 */
export function readAllMessage (data) {
  return request({
    url: '/api/v1/message/mark_all_read',
    method: 'post',
    data
  })
}
/**
 * 更新所有消息已读
 * http://192.168.88.247:4999/web/#/105/3323
 * @returns
 */
export function getUnReadMessage (params) {
  return request({
    url: '/api/v1/message/has_un_read',
    method: 'get',
    params
  })
}
